<template>
  <div class="statis-item-wrap">
    <el-tooltip :hide-after="888888" placement="bottom">
      <div slot="content" class="statis-item-content">
        <div v-if="rangekey === 'yearly'" class="tip-item" >全年所有资源预约统计</div>
        <div v-if="rangekey === 'curMonth'" class="tip-item" >当前月所有资源预约统计</div>
        <div v-if="rangekey === 'present'" class="tip-item">本月当前选中资源预约统计</div>
        <div class="tip-item">总数：{{ getStatisticsNum('total') | moneyFilter }}</div>
        <div class="tip-item">已确认数：{{ getStatisticsNum('success') | moneyFilter }}</div>
        <div class="tip-item">已取消数：{{ getStatisticsNum('fail') | moneyFilter }}</div>
        <div>待确认数：{{ getStatisticsNum('handding') | moneyFilter }}</div>
      </div>
      <div :class="{'bg-year': year,'bg-month':month,'bg-day':day}" class="statis-item-box">
        <div style="display:flex; font-weight:bold">
          <span class="label">{{ label }}：</span>
          <div class="data-item" style="margin-right:39px">
            <span class="sum" >{{ getStatisticsNum('total') | detailNumFormat }}</span>
          </div>
        </div>
        <div class="status-wrap">
          <div class="data-item">
            <div class="tick"><i class="el-icon-circle-check" /></div>
            <span class="sum">{{ getStatisticsNum('success') | detailNumFormat }}</span>
          </div>
          <div class="data-item">
            <div class="tick cancle"><i class="el-icon-circle-close" /></div>
            <span class="sum">{{ getStatisticsNum('fail') | detailNumFormat }}</span>
          </div>
          <div class="data-item" style="margin-right:5px">
            <div class="tick wait"><i class="el-icon-time" /></div>
            <span class="sum">{{ getStatisticsNum('handding') | detailNumFormat }}</span>
          </div>
        </div>
      </div>
    </el-tooltip>
  </div>
</template>
<script>
import { detailNumFormat, moneyFilter } from '@/filters/number';
export default {
  name: 'StatisItem',
  filters: {
    detailNumFormat,
    moneyFilter
  },
  props: {
    statistics: {
      type: Object,
      default: () => null
    },
    year: {
      type: Boolean,
      default: false
    },
    month: {
      type: Boolean,
      default: false
    },
    day: {
      type: Boolean,
      default: false
    },
    rangekey: {
      type: String,
      default: ''
    },
    label: {
      type: String,
      default: ''
    }
  },
  created() {
    this.getType();
  },
  methods: {
    getType() {

    },
    // 获取具体的统计数
    getStatisticsNum(key) {
      if (!this.statistics) return 0;
      if (this.rangekey in this.statistics) {
        return this.statistics[this.rangekey][key];
      } else {
        return 0;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.statis-item-wrap {
  display: flex;
  flex:1;
  align-items: center;
  font-size: 12px;
  color: #333333;
  .tip-item {
    // line-height: 20px;
    margin-bottom: 20px;
  }
  .statis-item-box {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    border-radius: 2px;
    padding:0 12px 0 8px;
  }
  .status-wrap{
    display: flex;
    flex: 1;
    justify-content: space-between;
    align-items: center;
  }
  .bg-year{
    background: #F7F9FF;
  }
  .bg-month{
    background: #FFFCF2;
  }
  .bg-day{
    background: #F4FCF2;
  }
  .data-item {
    display: flex;
    align-items: center;
    color: #999999;
    margin-right: 16px;
    .sum {
      white-space: nowrap;
      color: #333;
    }
  }
  .data-item:last-child {
    margin-right: 0px;
  }
  .tick {
    font-size: 16px;
    color: #406EFF;
    margin-right: 5px;
  }
  .wait {
    color: #F67943;
  }
  .cancle {
    color: #999;
  }
}

</style>
<style lang="scss">
.el-tooltip__popper {
  .statis-item-content {
    padding: 8px;
    > div {
      line-height: 18px;
    }
  }
}
</style>

